package com.neu.control;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.neu.daoimpl.Tb_empDaoImpl;
import com.neu.entity.Tb_emp;
import com.neu.service.Tb_empSession;


/**
 * Servlet implementation class tb_empcontrol
 */
@WebServlet("/tb_empcontrol")
public class tb_empcontrol extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public tb_empcontrol() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	/**
	 *   调用服务层
	 */
		PrintWriter out = response.getWriter();
		Tb_empSession ts = new Tb_empSession(new Tb_empDaoImpl());
		try {
			List<Tb_emp> list=new ArrayList<>();
			list=ts.select();
			Iterator<Tb_emp> ite=list.iterator();
			while(ite.hasNext()) {
				out.write(ite.next().toString());
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
